import 'package:equatable/equatable.dart';

/// 项目状态枚举
enum ProjectStatus {
  planning('PLANNING', '规划中'),
  inProgress('IN_PROGRESS', '进行中'),
  testing('TESTING', '测试中'),
  completed('COMPLETED', '已完成'),
  cancelled('CANCELLED', '已取消');

  const ProjectStatus(this.code, this.description);
  final String code;
  final String description;
}

/// 优先级枚举
enum Priority {
  high('HIGH', '高'),
  medium('MEDIUM', '中'),
  low('LOW', '低');

  const Priority(this.code, this.description);
  final String code;
  final String description;
}

/// 项目实体类
class Project extends Equatable {
  final int id;
  final String projectName;
  final String? description;
  final ProjectStatus status;
  final Priority priority;
  final String creatorName;
  final DateTime? deadline;
  final DateTime createTime;
  final DateTime updateTime;
  final TodoStats? todoStats;

  const Project({
    required this.id,
    required this.projectName,
    this.description,
    required this.status,
    required this.priority,
    required this.creatorName,
    this.deadline,
    required this.createTime,
    required this.updateTime,
    this.todoStats,
  });

  @override
  List<Object?> get props => [
        id,
        projectName,
        description,
        status,
        priority,
        creatorName,
        deadline,
        createTime,
        updateTime,
        todoStats,
      ];

  Project copyWith({
    int? id,
    String? projectName,
    String? description,
    ProjectStatus? status,
    Priority? priority,
    String? creatorName,
    DateTime? deadline,
    DateTime? createTime,
    DateTime? updateTime,
    TodoStats? todoStats,
  }) {
    return Project(
      id: id ?? this.id,
      projectName: projectName ?? this.projectName,
      description: description ?? this.description,
      status: status ?? this.status,
      priority: priority ?? this.priority,
      creatorName: creatorName ?? this.creatorName,
      deadline: deadline ?? this.deadline,
      createTime: createTime ?? this.createTime,
      updateTime: updateTime ?? this.updateTime,
      todoStats: todoStats ?? this.todoStats,
    );
  }
}

/// 待办任务统计
class TodoStats extends Equatable {
  final int total;
  final int completed;
  final int inProgress;
  final int todo;
  final int blocked;

  const TodoStats({
    required this.total,
    required this.completed,
    required this.inProgress,
    required this.todo,
    required this.blocked,
  });

  @override
  List<Object> get props => [total, completed, inProgress, todo, blocked];
}
